# define MaxSize 50
# define ElementType int

using namespace std;

// 队列被定义为，限制操作的线性表；
/*
队头(front):只允许删除
队尾(rear): 只允许插入
循环队列:首尾相连的队列
*/
struct Queue
{
    ElementType *data;
    int front,rear;
    Queue()
    {
        data = new int[MaxSize];
        for (int i=0;i<MaxSize;i++)
        {
            data[i] = -1;
        }
        front = 0;
        rear = 0;
    }

    bool QueueEmpty()
    {
        return (front == rear);
    }
    bool QueueFill()
    {
        return ((rear+1)%MaxSize == front);
    }
    bool EnQueue(ElementType x)
    {
        if (QueueFill())
            return 0;
        data[rear] = x;
        rear = (rear+1)%MaxSize;
        return 1;
    }
    int DeQueue()
    {
        if (QueueEmpty() == 1)
            return -1;
        else
        {
            int res = data[front];
            front = (front+1)%MaxSize;
            return res;
        }
    }
};



